package com.codebuffer.nowcoder;

import java.util.ArrayList;
import java.util.List;

public class EntryNodeOfLoop {

    public ListNode EntryNodeOfLoop(ListNode pHead) {

        List<ListNode> list = new ArrayList<>();
        ListNode node = pHead;
        while(node!=null){
            if(list.contains(node)){
                return node;
            }
            list.add(node);
            node = node.next;
        }
        return null;
    }


}

